<template>
  <q-search
    v-model="keyword"
    style="font-family: '微软雅黑';border: 1px solid #9999"
    placeholder="搜索地图名称或者地名"
    autofocus
    inverted-light
    hide-underline
    color="white"
    class="no-shadow"
    @keyup.enter="search">
    <q-btn dense icon="close" @click="$emit('close')"/>
    <!--<q-popover v-model="searchTipEnabled" fit>-->
    <!--<div class="q-ma-sm">-->
    <!--<div class="q-my-sm">热门标签</div>-->
    <!--<div class="row q-my-sm">-->
    <!--<div>-->
    <!--</div>-->
    <!--</div>-->
    <!--<div class="q-py-sm border-top-1">搜索历史</div>-->
    <!--<div>-->
    <!--<q-list no-border>-->
    <!--<q-item link>dsds</q-item>-->
    <!--<q-item link>dsds</q-item>-->
    <!--<q-item link>dsds</q-item>-->
    <!--<q-item link>dsds</q-item>-->
    <!--<q-item link>dsds</q-item>-->
    <!--</q-list>-->
    <!--</div>-->
    <!--</div>-->
    <!--</q-popover>-->
  </q-search>
</template>

<script>
  export default {
    name: 'layoutHeaderSearch',
    data () {
      return {
        keyword: ''
      }
    },
    created () {
      this.keyword = this.$route.params.keyword
    },
    computed: {
    },
    watch: {
    },
    methods: {
      search () {
        if (!this.keyword) {
          return
        }

        const history = this.$route.path
        let path = '/search/'

        if (history.match(/^\/forum/)) {
          path += 'forum/'
        } else {
          path += 'map/'
        }

        path += this.keyword

        this.history = history
        this.$router.push({ path: path })
      }
    }
  }
</script>

<style lang="stylus">
</style>
